using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace CHEnhanceEfCore.Config.Schedule.config
{
    public class QuartzBackgroundService : BackgroundService
    {
        private readonly IServiceProvider _serviceProvider;

        public QuartzBackgroundService(IServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;
        }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var scheduleService = _serviceProvider.GetService<QuartzConfigFactory>();
            await scheduleService.init();
        }
    }
}